package com.ecfront.dao.impl;

import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ecfront.dao.ShopDAO;
import com.ecfront.pojo.Shop;


/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class ShopDAOImpl extends HibernateDaoSupport implements ShopDAO {

	protected void initDao() {}


	public void save(Shop transientInstance) {
		getHibernateTemplate().saveOrUpdate(transientInstance);
	}

	public void delete(Shop persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);
	}


	public Shop findById(java.lang.Integer id) {
		Shop instance = (Shop) getHibernateTemplate().get(
					"com.ecfront.pojo.Shop", id);
		return instance;
	}


	public List findByExample(Shop instance) {
		List results = getHibernateTemplate().findByExample(instance);
		return results;
	}


	public List findByProperty(String propertyName, Object value) {
		String queryString = "from Shop as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);
	}

	public List findBySname(Object sname) {
		return findByProperty(SNAME, sname);
	}

	public List findBySnote(Object snote) {
		return findByProperty(SNOTE, snote);
	}

	public List findBySinfo(Object sinfo) {
		return findByProperty(SINFO, sinfo);
	}

	public List findBySlogoUrl(Object slogoUrl) {
		return findByProperty(SLOGO_URL, slogoUrl);
	}

	public List findBySisLock(Object sisLock) {
		return findByProperty(SIS_LOCK, sisLock);
	}

	public List findBySdomain(Object sdomain) {
		return findByProperty(SDOMAIN, sdomain);
	}

	public List findAll() {
		String queryString = "from Shop";
		return getHibernateTemplate().find(queryString);
	}

	public static ShopDAO getFromApplicationContext(ApplicationContext ctx) {
		return (ShopDAO) ctx.getBean("ShopDAO");
	}
}